package com.dubbo.consumer.Annotation;

import com.dubbo.dubbo.Annotation.IUserService;
import com.dubbo.dubbo.demo.IUserOperateService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class UserOperateService implements IUserOperateService {

    @DubboReference
    private IUserService userservice;

    @Override
    @HystrixCommand(fallbackMethod = "failBackMethod")
    public String GetHelloWorldReply(String userName) {
        return userservice.HelloHystrix(userName);
    }

    /**
     * 服务降级
     * @param userName
     * @return
     */
    public String failBackMethod(String userName) {
        return "service request fail - "+userName;
    }
}
